package com.register.controller;

import com.register.service.impl.QRDepotServiceImpl;
import com.register.service.impl.QRUserAndDepotServiceImpl;
import com.register.service.impl.UserServiceImpl;
import com.register.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.Map;

@Controller
public class IndexController {

    @Autowired
    QRDepotServiceImpl qrDepotService;
    @Autowired
    UserServiceImpl userService;
    @Autowired
    QRUserAndDepotServiceImpl qrUserAndDepotService;
    //首页controller
    @GetMapping("fab805f4-1d31-4e18-bc77-34abb7be4265")
    public String index(Model model){

        int qrDepotNum = qrDepotService.count();
        int usersNum = userService.count();
        int qrUserAndDepotNum = qrUserAndDepotService.count();
        Map<String,Object> map = new HashMap<>();
        map.put("qrDepotNum",qrDepotNum);
        map.put("usersNum",usersNum);
        map.put("qrUserAndDepotNum",qrUserAndDepotNum);
        model.addAttribute("result", Result.ok(map));
        return "index";
    }
}
